#include "stage.h"
#include "SimulationData.h"

#ifndef __ROBOTBASE_H__
#define __ROBOTBASE_H__

using namespace Stg;
using namespace std;

enum LogType {DebugLog, ErrorLog, NormalLog};

class RobotBase
{
    public:
        // Estimated group size
        int GroupSize;

        // ID of robot, got from wifi id
        unsigned int id;
        unsigned long communication;

        // Representation of devices
        ModelPosition *position;
        ModelLaser *laser;    //360 detection - index (0-7) start from the end of robot in counterclockwise
        ModelWifi *wifi;

        // Movement control
        int avoidcount, randcount;

        // Data file
        SimulationData *simData;

        bool verbose;
        bool processMsg;
        int movementType;

    public:
        // Constructor
        RobotBase(Model* model);

        // Deconstructor
        ~RobotBase() { };

        // What the robot does in every loop.
        void DoLoop();

        // Algorithm of group size estimation
        virtual void Estimate() { };

        // Return the state of the robot
        int IsActive();

        // Robot wander and avoid obstacles in the enviroment
        int Wander();
        void MoveStraight();

        void Broadcast(WifiMessageBase* msg);


        // Process message
        virtual void MessageReceive(WifiMessageBase* mesg) { };

    protected:
        unsigned int GetTime();
        void Log(string Msg, LogType type=NormalLog);
        void Sleep(unsigned int sec);
        int startx;

};// end Robot

const unsigned int VerboseList[] = {4, 8, 12};
const int VerboseNumber = 0;
const int MaxMove = 25;

#endif
